package com.ruoyi.androidPad.controller;

import com.ruoyi.androidPad.service.UploadService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * @author LiSuxuan
 * @date 2021年 08月 16日 19:24
 *
 * 安卓平板控制类，用于处理图片上传、设置参数
 */
@Api("androidPad")
@Slf4j
@RestController
@RequestMapping("/pad")
public class PadController extends BaseController {

    @Autowired
    private UploadService uploadService;

    @ApiOperation(value = "上传图片", notes = "note")
    @PostMapping("/upload")
    public AjaxResult uploadImg(String deviceID, @RequestParam("imageName") MultipartFile file) {
        try {
            uploadService.uploadFile(deviceID, file);
            return AjaxResult.success("成功");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return AjaxResult.error();
    }




}
